<?php if (!defined("_ECRIRE_INC_VERSION")) return; if (class_exists('pdk_Document_lien_model')) return; 
/**
 * SPIP Plugin Development Kit
 *
 * @author     Aleksey Yaroshchuk (aleksey.yaroshchuk@gmail.com)
 * @license    GNU/GPL
 * @package    plugins
 * @subpackage pdk
 * @category   outils
 * @copyright  (c) Aleksey Yaroshchuk 2011-2012
 * @link       http://www.spip-contrib.net/Developmet-Kit
 * @version    1.0.0
 */

include_spip('classes/pdk_model');
/**
 *  Document Class
 * 
 * 	This model represents SPIP document's lien (link beetwen document and object)
 *
 * @package		plugins
 * @subpackage	pdk
 * @category	outils
 * @author		Aleksey Yaroshchuk (aleksey.yaroshchuk@gmail.com)
 * @link		http://www.spip-contrib.net/Developmet-Kit
 */
class pdk_Document_lien_model extends pdk_Model {
    public function __construct() {
        parent::__construct();
        $this->config_model();        
    }
    
    function config_model() {
        // Define main table:
        $this->main_table = 'spip_documents_liens';
        
        // Define primary key:
        $this->primary_key = 'id_document';
        
        // Define main table fields:
        $this->main_fields['id_document'] = 'id_document'; 
        $this->main_fields['id_objet'] = 'id_objet';
        $this->main_fields['objet'] = 'objet';
        $this->main_fields['vu'] = 'vu';
                                                                                 
         // Define validation rules:
         $this->validation->set_rules( 
            array(
               array(
                     'field'   => 'id_document',
                     'label'   => 'ID document',
                     'rules'   => 'is_natural'
                  ),
               array(
                     'field'   => 'id_objet',
                     'label'   => 'ID object',
                     'rules'   => 'is_natural'
                  )
            )
         );                                       
    }
}
?>